#include<stdio.h>
#include<string.h>
int bin_search(int arr[], int left, int right, int key)
{
	
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (arr[mid]==key)
		{
			printf("%d\n", mid);
			return mid;
			break;
			
		}
		else if (arr[mid] < key )
		{
			left = mid + 1;
		}
		else if(arr[mid]>key)
		{
			right = mid - 1;
		}

	}
	
	return -1;
}
int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int left = 0, right = sizeof(arr) / sizeof(arr[0]) - 1, key;
	key = 6;
	bin_search(arr, left, right, 6);
	
	return 0;
}